﻿using Freshbox2._0.BLL;
using Freshbox2._0.MODEL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Freshbox2._0.UI.Controllers
{ 
    // [Freshbox2._0.UI.Filters.CheckLogin(IsCheck = true)]  ///xinjiade   新增的  适合 单独使用   不适合连起来使用
    public class HomeController : BaseController<feedback>
    {
        //
        // GET: /OneHome/
        protected admin CurrentUer

        {
            get { return Session["CurrentUer"] == null ? null : (admin)Session["CurrentUer"]; }
        }

        public override BLL.BaseBll<feedback> bll
        {
            get
            {
                return new FeedBackCusBll();
            }

        }



        LogBll logBll = new LogBll();

        AreaLogBll areaLogBll = new AreaLogBll();

        ManagerFeedBackBll mFeegBackBll = new ManagerFeedBackBll();


        public ActionResult GetNoRead()  //查看未读消息

        {
            string url = Request.RawUrl;
            DateTime todayNow = DateTime.Now;
            DateTime midnight = DateTime.Now;
            midnight = midnight.Date;
            //用户建议
            int countCus= bll.Search(x => x.feedbackTime <= todayNow && x.feedbackTime >= midnight&&x.IsRead==0).ToList().Count();
            //理货员下架记录通知  
            int logManager = logBll.Search(x => x.logTime <= todayNow && x.logTime >= midnight && x.logType == 0&&x.IsRead==0).ToList().Count();
            //理货员  建议消息
            int countmanager= mFeegBackBll.Search(x=>x.mfDate <= todayNow && x.mfDate >= midnight && x.IsRead == 0&&x.managerCode!=0).ToList().Count();
            //采销人员  下架记录消息
            int areaLogCount = areaLogBll.Search(x => x.logTime <= todayNow && x.logTime >= midnight && x.IsRead == 0).ToList().Count();
            return Json(new { cus = countCus, managerlog = logManager, maFeed = countmanager,areaLogCount=areaLogCount   },JsonRequestBehavior.AllowGet);
        }

    }
}
